package cn.youqu.happy.module.youqu.mq.consumer.user;

import cn.youqu.happy.framework.mq.core.pubsub.AbstractChannelMessageListener;
import cn.youqu.happy.module.member.mq.message.user.UserInfoRefreshMessage;
import cn.youqu.happy.module.youqu.service.userAssess.UserAssessService;
import cn.youqu.happy.module.youqu.service.userComment.UserCommentService;
import cn.youqu.happy.module.youqu.service.userTell.UserTellService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 针对 {@link UserInfoRefreshMessage} 的消费者
 *
 * @author 芋道源码
 */
@Component
@Slf4j
public class UserInfoRefreshConsumer extends AbstractChannelMessageListener<UserInfoRefreshMessage> {

    @Resource
    private UserTellService userTellService;

    @Resource
    private UserCommentService userCommentService;

    @Resource
    private UserAssessService userAssessService;

    @Override
    public void onMessage(UserInfoRefreshMessage message) {
        log.info("[onMessage][收到 用户信息 刷新消息]");
        userTellService.updateUserInfoToUserTell(message.getNickName(), message.getAvatar(), message.getUid());
        userCommentService.updateUserInfoToUserComment(message.getNickName(), message.getAvatar(), message.getUid());
        userAssessService.updateUserInfoToUserAssess(message.getNickName(), message.getAvatar(), message.getUid());
    }

}
